﻿<%@ page contentType="text/html; charset=utf-8"%>

<!DOCTYPE html>
<html>
<head>
    <title>明细报表：实现汇总报表向明细报表的透视(Drilldown) - WEB HTML5报表演示</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
	<script src="../grhtml5-6.6-min.js" type="text/javascript"></script>

    <script type="text/javascript">
        var reportViewer,
            subTitle;

        //在网页初始加载时设置参数并启动报表的运行显示
        function window_onload() {
            var BeginDate = '<%=request.getParameter("BeginDate")%>',
                EndDate = '<%=request.getParameter("EndDate")%>',
                CategoryID = '<%=request.getParameter("CategoryID")%>',
                ProductID = '<%=request.getParameter("ProductID")%>'
                City = '<%=request.getParameter("City")%>',
                CompanyName = '<%=request.getParameter("CompanyName")%>';

			if (CategoryID == "null") {
				CategoryID = "";
			}
			if (ProductID == "null") {
				ProductID = "";
			}
			if (City == "null") {
				City = "";
			}
			if (CompanyName == "null") {
				CompanyName = "";
			}
            if (BeginDate == "null") {
                BeginDate  = "1997-1-1";
            }
            if (EndDate == "null") {
                EndDate  = "1997-12-31";
            }

            document.getElementById("txtBeginDate").value = BeginDate;
            document.getElementById("txtEndDate").value = EndDate;
            document.getElementById("txtCategoryID").value = CategoryID;
            document.getElementById("txtProductID").value = ProductID;
            document.getElementById("txtCity").value = City;
            document.getElementById("txtCompanyName").value = CompanyName;

            reportViewer = window.rubylong.grhtml5.insertReportViewer("report_holder", "../../grf/SummaryToDetail/Detail.grf", "");

            reportViewer.report.OnInitialize = OnInitialize;

            btnRefresh_onclick();
        }

        function OnInitialize() {
            var report = reportViewer.report;

            //根据查询参数更新报表付标题，设置报表中的对应静态框的“Text”属性
            report.ControlByName("SubTitle").AsStaticBox.Text = subTitle;
        }

        //根据数据过滤参数重新显示报表
        function btnRefresh_onclick() {
			//TDD...City有汉字，需要进行编码转换，暂时未处理 String Utf8City = new String(City.getBytes("ISO-8859-1"), "UTF-8");  
            var BeginDate = document.getElementById("txtBeginDate").value,
                EndDate = document.getElementById("txtEndDate").value,
                CategoryID = document.getElementById("txtCategoryID").value,
                ProductID = document.getElementById("txtProductID").value,
                City = document.getElementById("txtCity").value,
                CompanyName = document.getElementById("txtCompanyName").value,
                dataURL = "../../data/DataCenter.jsp?data=FilterSaleDetail",
                params;
    
            subTitle = "日期范围: " + BeginDate + "至" + EndDate;
            params = "&BeginDate=" + BeginDate + "&EndDate=" + EndDate;
            if (CategoryID) {
                subTitle += " 产品类别: " + CategoryID;
                params += "&CategoryID=" + CategoryID;
            }
            if (ProductID) {
                subTitle += " 产品编号: " + ProductID;
                params += "&ProductID=" + ProductID;
            }
            if (City) {
                subTitle += " 客户城市: " + City;
                params += "&City=" + City;
            }
            if (CompanyName) {
                subTitle += " 公司名称: " + CompanyName;
                params += "&CompanyName=" + CompanyName;
            }
            dataURL += params;

            reportViewer.stop();
            reportViewer.dataURL = encodeURI(dataURL);
            reportViewer.start();
        }
    </script>
</head>
<body style="" onload="window_onload()">
    <div style="">
        <span>开始日期：</span>
        <input id="txtBeginDate" type="text" value="1997-1-1" maxlength="20" style="width: 84px" />
        <span>结束日期：</span>
        <input id="txtEndDate" type="text" value="1997-12-31" maxlength="20" style="width: 80px" />

        <span>产品类别ID:</span>
        <input id="txtCategoryID" type="text" size="3" value="" />
        <span>产品ID:</span>
        <input id="txtProductID" type="text" size="3" value="" />

        <span>客户城市:</span>
        <input id="txtCity" type="text" size="8" value="" />
        <span>公司名称:</span>
        <input id="txtCompanyName" type="text" size="16" value="" />

        <input id="btnRefresh" onclick="return btnRefresh_onclick()" type="button" value="更新显示" />
    </div>
    <div id="report_holder">报表占位标签</div>
</body>
</html>
